


Ext.onReady(function(){
	upPwdiswriteidb= Ext.get('upPwdiswriteid').getValue()==1?true:false;
	
	var upPwdUserNameField=new Ext.form.TextField({
		fieldLabel:'用户姓名',
		value:Ext.get('upPwdsUserName').getValue(),
		disabled:true
	});
	var upPwdUsersAccontField=new Ext.form.TextField({
		fieldLabel:'用户账号',
		value:Ext.get('upPwdsAccount').getValue(),
		disabled:true
	});
	var upPwdUserSpwdField=new Ext.form.TextField({
		fieldLabel:'原始密码',
		inputType:'password',
		allowBlank:false
	});
	var upPwdUserNpwdField=new Ext.form.TextField({
		fieldLabel:'新密码',
		inputType:'password',
		allowBlank:false
	});
	var upPwdUserNpwdconfirmField=new Ext.form.TextField({
		fieldLabel:'确认密码',
		inputType:'password',
		allowBlank:false
	});
	
	var upPwdupbtn=new Ext.Button({
		text:'修 改',
		hidden:upPwdiswriteidb,
		style:'margin-left:100px;margin-top:20px',
		handler:function(){

			if(!upPwdUserSpwdField.validate()){
				Ext.Msg.alert('信息','原始密码不能为空！');
				return false;
			}
			if(!upPwdUserNpwdField.validate()){
				Ext.Msg.alert('ERROR','新密码不能为空！');
				return false;
			}
			if(upPwdUserNpwdField.getValue()!=upPwdUserNpwdconfirmField.getValue()){
				Ext.Msg.alert('ERROR','两次密码不一致！');
				return false;
			}
			
			Ext.Ajax.request({
				url:'updatePwd.do',
				method:'POST',
				params : {
				   'sAccount':Ext.get('upPwdsAccount').getValue(),
				   'lpwd':	upPwdUserSpwdField.getValue(),
                   'qpwd' :	upPwdUserNpwdField.getValue()
                }, 
  				success: function (response) {

  					if(response.responseText=='-1'){
                        Ext.MessageBox.alert('信息!', '原始密码不正确!');
  					}
  					else if(response.responseText=='1'){
  						Ext.Msg.alert("信息","密码修改成功！"); 
  					}else{
  						Ext.Msg.alert('ERROR','密码修改失败! ');
  					}
              	}, 
  				failure: function (response) {
                    Ext.Msg.alert("Error","错误"); 
            	}
			});
			
		}
	});
	
	var upPwdformPanel=new Ext.FormPanel({
		region:'center',
		frame:true,
		labelAlign:'right',
		items:[upPwdUserNameField,upPwdUsersAccontField,upPwdUserSpwdField,
			upPwdUserNpwdField,upPwdUserNpwdconfirmField,upPwdupbtn
		]
	});
	
	var upPwdMainPanel =new Ext.Viewport({
		layout:'border',
		renderTo:'upPwdDIV',
		id:'upPwdMainPanel',
		items:[upPwdformPanel],
		listeners: {
	        'resize': function(viewport,adjWidth,adjHeight,rawWidth,rawHeight)  {
	          	Ext.getCmp("upPwdMainPanel").setHeight((document.body.clientHeight - 290) * 0.67);  
			}
    	}
	});
	
});